import request from '@/axios'
import { User } from './type'
import { useUserStoreWithOut } from '@/store/modules/user'

enum api {
  login = '/auth/login',
  refresh = '/auth/refreshToken'
}

// 登录
export const loginApi = (user: User) => {
  return request.post(api.login, user)
}

// 刷新token
export const refreshTokenApi = () => {
  const userStore = useUserStoreWithOut()
  return request.get(api.refresh, { refresh_token: userStore.getRefreshToken })
}